﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SewerAPI.Core
{
    public class Statistic
    {
        #region Public Fields

        /// <summary>
        /// The message type
        /// </summary>
        public MessageType MessageType { get; private set; }

        /// <summary>
        /// The transaction type
        /// </summary>
        public MessageTransaction Transaction { get; private set; }

        /// <summary>
        /// The channel
        /// </summary>
        public string Channel { get; private set; }

        /// <summary>
        /// The date created
        /// </summary>
        public DateTime DateCreated { get; private set; }

        #endregion

        /// <summary>
        /// Private constructor
        /// </summary>
        private Statistic() { }

        #region Factory Methods

        /// <summary>
        /// Create a statistic
        /// </summary>
        /// <param name="message"></param>
        /// <param name="transaction"></param>
        /// <param name="channel"></param>
        /// <returns></returns>
        public static Statistic Create(Message message, string channel = null)
        {
            Statistic _s = new Statistic();
            _s.MessageType = message.MessageType;
            _s.Transaction = message.Transaction;
            _s.Channel = (channel == null) ? message.Channel : channel;
            _s.DateCreated = DateTime.Now;
            return _s;
        }

        #endregion
    }
}
